#!/bin/bash -e
# $File: genpot
# $Date: Fri Feb 17 17:32:09 2012 +0800
# $Author: jiakai <jia.kai66@gmail.com>

txtgrn='\e[0;32m' # Green
txtwht='\e[0;37m' # White
txtrst='\e[0m'    # Text Reset

function print_msg()
{
	echo -e "${txtwht}${1}${txtgrn}"
}

print_msg  "Extracting from mako templates ... "

pushd . >/dev/null

cd ../..

. ./init.sh

FOUT=utils/nls/pynojo.pot

eval $(grep 'RELEASE =' pynojo/config/pkg.py | sed -e 's/ //g')


pybabel extract \
	--no-default-keywords --omit-header \
	--keyword=_  --keyword=_pl:1,2 \
	-F utils/nls/babel.cfg \
	-o - . > "$FOUT"

print_msg "Extracting from python source ..."
find pynojo -name "*.py" | \
	xgettext --copyright-holder 'pynojo development team' --package-name pynojo \
	--package-version "$RELEASE" --from-code=UTF-8 --keyword=_  \
	--keyword=_pl:1,2 -f - -o "$FOUT" -j

print_msg 'running aspell, note that the personal directionary is wordlist.txt'
print_msg 'misspelled words: '

tail -n +20 "$FOUT" | grep -v '^\(#\|msgstr\)' | \
	sed -e 's/^msgid[_a-z]*//g' | \
	(popd >/dev/null && aspell list -d en_US --personal ./wordlist.txt)

echo -e $txtrst
# vim: ft=sh
